import { configureStore, getDefaultMiddleware } from '@reduxjs/toolkit';
import { save, load } from 'redux-localstorage-simple'

import counter from './counter/reducer'
import user from './user/reducer'
import common from './common/reducer';

const PERSISTED_KEYS: string[] = []

const store = configureStore({
    reducer: {
        counter,
        user,
        common
    },
    middleware: [...getDefaultMiddleware({ thunk: false }), save({ states: PERSISTED_KEYS })],
    preloadedState: load({ states: PERSISTED_KEYS })
})

export default store

export type AppState = ReturnType<typeof store.getState>
export type AppDispatch = typeof store.dispatch